<template>
  <div>
    <div class="item" @click="toJobDetailHandler" v-if="listItem?.title">
      <div>
        <div>{{ listItem.title }}</div>
        <div>{{ listItem.salary }}</div>
      </div>
      <div>
        {{ listItem.workAddress }} | {{ listItem.workRange }} |
        {{ listItem.education }}
      </div>
      <div>
        <div v-for="(welfare, index) in listItem.welfare" :key="index">
          {{ welfare }}
        </div>
      </div>
      <div @click.stop="toCompanyDetailHandler" v-if="listItem?.companyInfo">
        <div>
          <img :src="listItem.companyInfo[0].logoUrl" alt="" />
        </div>
        <div>
          <div>{{ listItem.companyInfo[0].titleIn }}</div>
          <div>
            {{ listItem.companyInfo[0].companyType }}
            {{ listItem.companyInfo[0].companyNumber }}
          </div>
        </div>
        <div v-if="!isJobDetail" @click.stop="$router.push('/chat')">立即投递</div>
      </div>
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "JobComponent",
  props: {
    listItem: {
      type: Object,
      default: ()=>({}),
    },
    isJobDetail:{
      type:Boolean,
      default:false
    }
  },
  methods: {
    //跳转到公司详情
    toCompanyDetailHandler(){
      this.$router.push(`/companydetail?id=${this.listItem?.companyInfo[0]._id}`);
    },
    //跳转到岗位详情
    toJobDetailHandler() {
      this.$router.push({
        path:"/jobdetail",
        query:{
          id:this.listItem._id
        }
      })
    },
  },
};
</script>

<style lang="scss" scoped>
.item {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.3rem 0.35rem 0.32rem;
  border-bottom: 1px solid #f4f4f4;
  > div {
    text-align: start;
    &:nth-child(1) {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 0.36rem;
      > div {
        font-weight: 400;
        &:nth-child(2) {
          font-weight: 500;
          color: #149639;
        }
      }
    }
    &:nth-child(2) {
      width: 100%;
      font-size: 0.2rem;
      font-weight: 300;
      color: #333333;
      margin-top: 0.19rem;
    }
    &:nth-child(3) {
      width: 100%;
      margin-top: 0.19rem;
      display: flex;
      flex-wrap: wrap;
      > div {
        background: #f4f4f4;
        border-radius: 0.08rem;
        padding: 0.08rem 0.16rem;
        font-size: 0.2rem;
        margin-right: 0.1rem;
      }
    }
    &:nth-child(4) {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 0.3rem;
      > div {
        &:nth-child(1) {
          width: 0.6rem;
          height: 0.6rem;
          margin-right: 0.14rem;
          border-radius: 50%;
          overflow: hidden;
        }
        &:nth-child(2) {
          flex-grow: 1;
          font-size: 0.27rem;
          font-weight: 400;
          color: #333333;
          > div {
            &:nth-child(2) {
              font-size: 0.18rem;
              color: #aaa;
            }
          }
        }
        &:nth-child(3) {
          width: 1.3rem;
          height: 0.5rem;
          background: #ffffff;
          border: 0.02rem solid #149639;
          border-radius: 0.25rem;
          font-size: 0.24rem;
          font-weight: 400;
          color: #149639;
          line-height: 0.5rem;
          text-align: center;
        }
      }
    }
  }
}
</style>